package com.examples.table;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

public class TableItemExample {

  public static void main(String[] a) {
    final Display d = new Display();
    final Shell s = new Shell(d);

    s.setSize(250, 200);
    s.setText("A Table Shell Example");
    s.setLayout(new FillLayout());

    Table t = new Table(s, SWT.NONE);
    t.setHeaderVisible(true);
    
    TableColumn tc1 = new TableColumn(t, SWT.CENTER);
    tc1.setText("First Name");
    TableColumn tc2 = new TableColumn(t, SWT.CENTER);
    tc2.setText("Last Name");
    TableColumn tc3 = new TableColumn(t, SWT.CENTER);
    tc3.setText("Mobile Number");
    tc1.setWidth(70);
    tc2.setWidth(70);
    tc3.setWidth(100);
    
    TableItem t1 = new TableItem(t, SWT.NONE);
    t1.setText(new String[]{"Vidit","Mongia","8447478321"});
    TableItem t2 = new TableItem(t, SWT.NONE);
    t2.setText(new String[]{"Rahul","Yadav","9587220156"});
    
    s.open();
    while (!s.isDisposed()) {
      if (!d.readAndDispatch())
        d.sleep();
    }
    d.dispose();
  }
}